#!/bin/bash
#执行脚本前，将sshpass压缩包放入家目录
#此脚本在家目录下执行
{
cd /root/
tar -xf sshpass-1.08.tar.gz && echo "sshpass已解压到当前目录下"
cd sshpass-1.08
./configure &> /dev/null && make &> /dev/null && make install &> /dev/null && echo "sshpass编译安装成功"
rm -rf /root/.ssh
HOSTS="
192.168.204.101
192.168.204.102
192.168.204.103
192.168.204.104
"
PASS=123456
ssh-keygen -P "" -f /root/.ssh/id_rsa &> /dev/null
for i in $HOSTS;do
	sshpass -p $PASS ssh-copy-id -o StrictHostKeyChecking=no -i /root/.ssh/id_rsa.pub $i &> /dev/null
	scp -rp /root/.ssh $i:/root/
done
echo "免密登录配置成功"
}